package com.company.ywj;

import java.util.HashMap;
import java.util.Map;

public class Einstein {

    public static void main(String[] args){
        int red, white, green, yellow, blue = 0;
        int britain, swedish, denmark, norway, germany = 0;
        int tea, coffee, beer, water, milk = 0;
        int PALL_MALL, DUNHILL, BLENDS, BLUEMASTER, PRINCE = 0;
        int dog, bird, horse, cat, fish = 0;
        // 挪威人住在第一个房子里
        norway = 0;
        // 挪威人和住蓝房子的人相邻->蓝色房子为第二间房
        blue = 1;
        // 住中间房子的人喝牛奶
        milk = 2;
        for(red = 0;red < 5;red++){
            if(red == blue){
                continue;
            }
            // 英国人住在红色房子里
            britain = red;
            // 绿色紧挨白色且在白色房子的左边->白色不为前三间房子
            for(white = 3;white<5;white++){
                if(red == white){
                    continue;
                }
                // 绿色房子紧挨着白色房子，在白色房子的左边
                green = white - 1;
                // 绿色房子的主人喝咖啡
                coffee = green;
                for(yellow = 0;yellow<5;yellow++){
                    // 颜色不同且蓝色房子为第二间
                    if(red == yellow | white == yellow | yellow == 1 | green == yellow | green == red){
                        continue;
                    }
                    // 黄色房子里的人抽DUNHILL
                    DUNHILL = yellow;
                    for(dog = 0;dog<5;dog++){
                        // 瑞典人养狗
                        swedish = dog;
                        for(bird = 0;bird<5;bird++){
                            if(dog == bird){
                                continue;
                            }
                            // 抽PALL_MALL香烟的人养鸟
                            PALL_MALL = bird;
                            for(horse = 0;horse<5;horse++){
                                if(dog == horse | bird == horse){
                                    continue;
                                }
                                for(cat = 0;cat<5;cat++){
                                    if(dog == cat | bird == cat | horse == cat){
                                        continue;
                                    }
                                    for(fish = 0; fish<5;fish++){
                                        if(dog == fish | bird == fish | horse == fish | cat == fish){
                                            continue;
                                        }
                                        for(tea = 0;tea<5;tea++){
                                            // 中间房子喝牛奶
                                            if(tea == 2 | tea == coffee){
                                                continue;
                                            }
                                            // 丹麦人喝茶
                                            denmark = tea;
                                            for(beer = 0;beer<5;beer++){
                                                if(tea == beer | beer == 2 | coffee == beer){
                                                    continue;
                                                }
                                                // 抽BLUEMASTER香烟的人喝啤酒
                                                BLUEMASTER = beer;
                                                for(water = 0;water<5;water++){
                                                    if(tea == water | beer == water | water == 2 | coffee == water){
                                                        continue;
                                                    }
                                                    for(BLENDS = cat - 1;BLENDS < cat + 2;BLENDS++){
                                                        if(BLENDS == cat | BLENDS == PALL_MALL | BLENDS == DUNHILL | BLENDS == BLUEMASTER | BLENDS == -1 | BLENDS == 5){
                                                            continue;
                                                        }
                                                        for(PRINCE = 0;PRINCE<5;PRINCE++){
                                                            if(PRINCE == BLENDS | PRINCE == PALL_MALL | PRINCE == DUNHILL | PRINCE == BLUEMASTER){
                                                                continue;
                                                            }
                                                            // 德国人抽PRINCE香烟
                                                            germany = PRINCE;
                                                            // 养马的人和抽DUNHILL牌香烟的人相邻
                                                            if(horse == DUNHILL - 1 | horse == DUNHILL + 1){
                                                                if(britain == swedish | britain == denmark | britain == norway | britain == germany |
                                                                swedish == denmark | swedish == norway | swedish == germany|
                                                                denmark == norway | denmark == germany|
                                                                norway == germany){
                                                                    continue;
                                                                }
                                                                if(PALL_MALL == DUNHILL | PALL_MALL == BLUEMASTER | DUNHILL == BLUEMASTER | coffee == milk){
                                                                    continue;
                                                                }
                                                                System.out.println("red="+red+"\twhite="+white+"\tgreen="+green+"\tyellow="+yellow+"\tblue="+blue+
                                                                        "\nbritain="+britain+"\tswedish="+swedish+"\tdenmark="+denmark+"\tnorway="+norway+"\tgermany="+germany+
                                                                        "\ntea="+tea+"\tcoffee="+coffee+"\tbeer="+beer+"\twater="+water+"\tmilk="+milk+
                                                                        "\nPall="+PALL_MALL+"\tDUN="+DUNHILL+"\tBLE="+BLENDS+"\tBLU="+BLUEMASTER+"\tPRI="+PRINCE+
                                                                        "\ndog="+dog+"\tbird="+bird+"\thorse="+horse+"\tcat="+cat+"\tfish="+fish);
                                                            }else {
                                                                continue;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
